package com.lw.carmanage.controller;

import com.lw.carmanage.dto.R;
import com.lw.carmanage.pojo.Car;
import com.lw.carmanage.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 * @version 1.0
 * @description:
 * @date 2022/4/4 18:51
 */
@RestController
@RequestMapping("/cars")
public class CarController {

    private CarService carService;

    @Autowired
    public void setCarService(CarService carService) {
        this.carService = carService;
    }

    @PostMapping("/add")
    public R addCar(@RequestBody Car car){
        carService.addCar(car);
        return R.setOK();
    }

    @GetMapping("/find/{id}")
    public R findById(@PathVariable Long id){
        return R.setOK(carService.findById(id));
    }
}
